<template>
  <div>
    <img src="../../assets/img/logo.png" alt />
    <div class="login">
      账号:
      <input type="text" v-model="user.phone" />
      <br />密码:
      <input type="text" v-model="user.password" />
      <br />
      <button @click="login">登录</button>
    </div>
  </div>
</template>

<script>
import { reqLogin } from "../../http/api";
export default {
  data() {
    return {
      type: "1",
      user: {
        phone: "",
        password: "",
      },
    };
  },
  methods: {
    login() {
      reqLogin(this.user).then((res) => {
        console.log(res);
        if (res.data.code == 200) {
          localStorage.setItem("islogin", true);
          localStorage.setItem("type", this.type);
          localStorage.setItem("user", JSON.stringify(res.data.list));
          this.$router.push("/index/home")
        }
      });
    },
  },
};
</script>

<style scoped>
img {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 0%);
}
.login {
  width: 100%;
  /* height: 1.6rem; */
  /* background: tomato; */
  text-align: center;
  position: absolute;
  bottom: 2.3rem;
  font-size: 0.5rem;
}
button {
  width: 2rem;
  margin-top: 0.6rem;
  background: tomato;
  border: none;
  border-radius: 0.1rem;
}
</style>